<?php

error_reporting(E_ALL);
	 
function DbInit()
{
	global $db;
	
	$options = array();
	
	$connstr = "mysql:host=localhost;dbname=hamilton";
	$db = new PDO($connstr, "hamilton", "only4hamilton", $options);
	$db->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);
	
	// Make sure our connections use utf8.
	$db->exec("SET NAMES utf8");
}

function TestBatch()
{
	global $db;
	$sql = "CREATE TEMPORARY table b (t varchar(20))";
	$sql2 = " INSERT INTO b VALUES ('hello')";
	/* This works
	$db->exec($sql);
	$db->exec($sql2);
	*/
	/* This fails because the subsequent query gives 2013 Lost connection
to MySQL server during query */
	$db->exec($sql . ";" . $sql2);	
	$sth = $db->query("SELECT * FROM b");
	var_dump($sth->fetchAll(PDO::FETCH_ASSOC));
}

DbInit();
TestBatch();

?>
